package com.oop.demo04;
//程序设计要求：外部低耦合，内部高内聚
//封装 ：属性私有，get/set
public class Students {

    private String name;//姓名
    private  int id;    //学号
    private int age;      //年龄
    private  char gender;  //性别
    //快捷键：选中私有变量名，alt+enter
    //要操作以上private的属性，就要用get/set
    //2、得到这个数据的值
    public String getName() {
        return name;
    }
     //1、给这个数据设值

    public void setName(String name) {
        this.name = name;
    }
      //获取年龄
    public int getAge() {
        return age;
    }
      //设置年龄
    public void setAge(int age) {

        if(age>120 || age<0){
            System.out.println("你怕是个傻子吧!");
        } else
             this.age = age;
    }

    

}
